<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <link rel="stylesheet" href="./css/login.css">
    <title>品言健康预约挂号系统</title>
    <link rel="stylesheet" href="./plugins/nprogress/number-pb.css">
    <style>
        .msg {
            position: absolute;
            top: 32%;
            left: 23%;
            width: 300px;
            height: 50px;
            border-radius: 5px;
            background: rgba(0, 0, 0, 0.6);
            transition: all 0.5s ease;
            display: none;
        }

        .msg.active {
            display: block;
        }

        .msg_font {
            color: #fff;
            display: block;
            text-align: center;
            line-height: 50px;
        }

        #shadow {
            width: 100%;
            height: 100%;
            z-index: 2;
            position: absolute;
            top: 0;
            left: 0;
            opacity: 0.8;
        }

        .mask-layer {
            display: none;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            position: fixed;
            background: transparent;
            z-index: 9999;
        }
    </style>
    <script src="js/axios.min.js"></script>
</head>

<body >
<div id="shadow">
    <div id="login-box">
        <div class="login_top">
            <img src="images/login/sth.png" alt="">
            <div class="logo_name" style="width: 230px;margin-left: 30px;">孙泰和</div>
            <div class="logo_name" style="width: 200px;margin-left: 40px;">号源池管理系统</div>
        </div>
        <div class="mask-layer"></div>
        <div class="login-center">

            <div class="login" style="margin-top: 37px">
                <form class="form-horizontal" id="loginForm" autocomplete="off">
                    <input type="hidden" name="appId" value="3"/>
                    <input type="hidden" name="resource" value="pc"/>
                    <div class="username">
                        <p><input name="userName" placeholder="请输入用户名"  type="text" id="sample"></p>
                        <img src="images/login/name.png" class="img">
                    </div>
                    <div class="password">
                        <p><input name="password" placeholder="请输入密码"  type="password"></p>
                        <img src="images/login/passwordNew.png" class="img">
                    </div>
                    <div class="yzm" >
                        <p><input name="code" placeholder="请输入验证码"></p>
                        <button onclick="getCode()" type="button"  class="bt-yzm" >
                            <img src="images/yzm/44390032020000.png" id="img-yzm" style="width: 120px;height: 47px">
                        </button>
                    </div>

                    <div class="unitId" hidden >
                        <select name="unitId" id="unitId" >
                            <option value="330000">杭州第一人民医院</option>
                            <option value="330001">杭州第二人民医院</option>
                            <option value="330002">杭州第三人民医院</option>
                            <option value="330003" selected>杭州第四人民医院</option>
                        </select>
                        <img src="images/login/hos.png" class="img">
                    </div>
                    <div class="confirm">
                        <button onclick="login()" type="button" id="confirm">登录</button>

                        <div class="forgetPassword" hidden>忘记密码?</div>
                    </div>
                </form>
            </div>

            <div class="msg">
                <span class="msg_font"></span>
            </div>
        </div>
    </div>
</div>
</body>

<script>if (typeof module === 'object') {
    window.module = module;
    module = undefined;
}</script>
<!-- normal script imports etc  -->
<script src="plugins/jQuery/jquery-1.11.1.js"></script>
<script type="text/javascript" src="plugins/layui/layer.js"></script>
<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>
<script src="js/axios.min.js"></script>
<!-- 参数定义 -->
<script src="js/constants.js"></script>

<script src="js/param.js"></script>
<!-- 工具类 -->
<script src="js/tools.js"></script>
<script src="./plugins/nprogress/jquery.velocity.min.js"></script>
<!--<script type="text/javascript" src="js/canvas-particle.js"></script>-->
<script src="./js/changeBackground.js"></script>


<script language="JavaScript">
    changeBackground()    // 节假日改变壁纸
    var sUserAgent = navigator.userAgent.toLowerCase();
    window.nodeRequire = undefined
    let electron;
    $("#loginForm p input").on("keydown", function (e) {
        if (e.keyCode == 13) {
            if ($(".username input").val() && $(".password input").val()) login()
            else if ($(".username input").val() && !$(".password input").val()) $(".password input").focus()
        }
    })


    getCode();

    //回车事件
    var id = '';
    var flag = true;
    function getCode() {
        axios.get("http://"+window.location.host+'/pubStaffInfo/verifyCode',{}).then(res => {
           console.log("res",res.data)
            // $("#imgId").attr('src','images/yzm/42364166608800.png');
            let image=document.getElementById('img-yzm');
            image.setAttribute('src',"/"+res.data+"");
        }).catch((e) => {
            console.log(e)

        });
    }

    function login() {
        $.extend(Param.formPost, {
            isToken: false,
            url: '/login',
            callback: function (data) {
                Param.initPageUser(data);

                localStorage.setItem("user", JSON.stringify(data));
                window.location.href = "indexList.html?appId="
                    + Param.user.appId + "&token=" + Param.user.token
                    + "&name=" + Param.user.name;
            }
        });

        $.ajax({
            async: false,
            type: "POST",
            dataType: "json",
            url: Param.host_url + "/pubStaffInfo/login",
            data: $(Param.formPost.formName).serialize(),
            success: function (data, textStatus) {
                data.token="2fc3c646-0851-492b-8d8d-074f7e84e8fb";
                if (data.token != null) {
                    Param.formPost.callback(data);
                } else {
                    $('.msg').removeClass('active')
                    $('.msg').css('display', 'block')
                    $('.msg').addClass('active')
                    $('.msg_font').html(data.msg)
                    setTimeout(function () {
                        $('.msg').css('display', 'none')
                    }, 200)
                    layer.alert(data.message)
                }

            },
            error: function (jqXHR) {
                alert('请输入正确的账户名密码!')
            }
        });
    }
    //页面加载时光标聚焦
    window.onload = function ()
    {
        var input = document.getElementById("sample");
        input.focus();
    }
</script>
